import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { UserModule } from './modules/user.module';
import { PhotoModule } from './modules/photo.module';
import { HttpExceptionFilter } from './common/filters/http-exception.filter';
declare const module: any; //热加载添加部分

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.useGlobalFilters(new HttpExceptionFilter());//使用全局异常过滤器
  const config = new DocumentBuilder()
    .setTitle('zoom example')
    .setDescription('The zoom API description')
    .setVersion('1.0')
    .addTag('zoom')
    .build();
  const document = SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('api', app, document);

  await app.listen(3000);
  //热加载添加部分
  if (module.hot) {
    module.hot.accept();
    module.hot.dispose(() => app.close());
  }
}
bootstrap();
